package com.ruoyi.web.controller.admin;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.WxJump;
import com.ruoyi.system.service.IWxJumpService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 微信跳转，生成链接Controller
 *
 * @author ruoyi
 * @date 2024-09-24
 */
@RestController
@RequestMapping("/system/jump")
public class WxJumpController extends BaseController
{
    @Autowired
    private IWxJumpService wxJumpService;

    /**
     * 查询微信跳转，生成链接列表
     */
    @PreAuthorize("@ss.hasPermi('system:jump:list')")
    @GetMapping("/list")
    public TableDataInfo list(WxJump wxJump)
    {
        startPage();
        List<WxJump> list = wxJumpService.selectWxJumpList(wxJump);
        return getDataTable(list);
    }

    /**
     * 导出微信跳转，生成链接列表
     */
    @PreAuthorize("@ss.hasPermi('system:jump:export')")
    @Log(title = "微信跳转，生成链接", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WxJump wxJump)
    {
        List<WxJump> list = wxJumpService.selectWxJumpList(wxJump);
        ExcelUtil<WxJump> util = new ExcelUtil<WxJump>(WxJump.class);
        util.exportExcel(response, list, "微信跳转，生成链接数据");
    }

    /**
     * 获取微信跳转，生成链接详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:jump:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(wxJumpService.selectWxJumpById(id));
    }

    /**
     * 新增微信跳转，生成链接
     */
    @PreAuthorize("@ss.hasPermi('system:jump:add')")
    @Log(title = "微信跳转，生成链接", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WxJump wxJump)
    {
        return toAjax(wxJumpService.insertWxJump(wxJump));
    }

    /**
     * 修改微信跳转，生成链接
     */
    @PreAuthorize("@ss.hasPermi('system:jump:edit')")
    @Log(title = "微信跳转，生成链接", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WxJump wxJump)
    {
        return toAjax(wxJumpService.updateWxJump(wxJump));
    }

    /**
     * 删除微信跳转，生成链接
     */
    @PreAuthorize("@ss.hasPermi('system:jump:remove')")
    @Log(title = "微信跳转，生成链接", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(wxJumpService.deleteWxJumpByIds(ids));
    }
}
